<!--优先级管理组件 -->
<template>
  <div >
	<div>
		<el-input placeholder="关键词" v-model="keyword"style="width: 200px;"></el-input>
		<el-button type="primary" size="mini" @click="load" >搜素</el-button>
		<el-button type="primary" size="mini"@click="open">添加</el-button>
	</div>
	 <el-table :data="datas"style="width: 100%" >
		<el-table-column type="selection"  ></el-table-column>
		<el-table-column prop="priorityCode" label="优先级度Id"></el-table-column>
		<el-table-column prop="priorityDesc" label="优先级名称"></el-table-column>
		<el-table-column prop="moduleState" :formatter="state" label="优先级状态"></el-table-column>
		<el-table-column prop="createBy" label="优先级创建人"></el-table-column>
		<el-table-column prop="createTime" label="优先级创建时间"></el-table-column>
		<el-table-column prop="modifyBy" label="优先级修改人"></el-table-column>
		<el-table-column prop="modifyTime" label="修改时间"></el-table-column>
	
		<el-table-column  label="操作">
			<template slot-scope="scope">
				<el-button type="primary" icon="el-icon-edit" size="mini" circle
				 @click="openchange(scope.row)" >
					修改</el-button>
			</template>
		</el-table-column>
	</el-table>	
	
	<!-- 添加缺陷优先级的方法 -->
		
	 <el-dialog title="添加优先级" :visible.sync="dialogTableVisible " >
	  <el-form  label-width="80px"  >
	    <el-form-item label="优先级描述">
	      <el-input v-model="addpriorityParam.priorityDesc"></el-input>
	    </el-form-item>
		<el-form-item label="优先级名称">
		  <el-input v-model="addpriorityParam.priorityName"></el-input>
		</el-form-item>
	    <el-form-item label="创建人">
	      <el-input v-model="addpriorityParam.createBy"></el-input>
	    </el-form-item>
	    <el-form-item label="创建时间" >
			<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss"type="date"
			 placeholder="选择日期" v-model="addpriorityParam.createTime">
	   
			</el-date-picker>
		</el-form-item>
	</el-form>
	   <div slot="footer" >
	         <el-button @click="dialogTableVisible=false">取 消</el-button>
	         <el-button type="primary" @click="addPriority">提交</el-button>
	    </div>
	 </el-dialog>
	 <!-- 修改缺陷优先级的弹出框-->
	  <el-dialog title="修改缺陷优先级" :visible.sync="changeTableVisible " >
	   <el-form  label-width="80px"  >
		   <el-form-item label="优先级的id">
		     <el-input v-model="changePriority.priorityCode"></el-input>
		   </el-form-item>
	     <el-form-item label="优先级描述">
	       <el-input v-model="changePriority.priorityDesc"></el-input>
	     </el-form-item>
	 
	     <el-form-item label="优先级状态">
	       <el-input v-model="changePriority.moduleState"></el-input>
	     </el-form-item>
	 			 <el-form-item label="创建人">
	 			   <el-input v-model="changePriority.createBy" 
	 			   :disabled="changePriority.createBy !=null"></el-input>
	 			 </el-form-item>
	     <el-form-item label="创建时间" >
	 		<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss"type="date"
	 		 placeholder="选择日期" 
	 				 :disabled="changePriority.createTime!=null"
	 				  v-model="changePriority.createTime">
	 				</el-date-picker>
	 			</el-form-item>
	 			<el-form-item label="修改人">
	 			  <el-input v-model="changePriority.modifyBy"></el-input>
	 			</el-form-item>
	 			<el-form-item label="修改时间" >
	 				<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss"type="date"
	 				 placeholder="选择日期" v-model="changePriority.modifyTime">
	 				</el-date-picker>
	 			</el-form-item>
	 </el-form>
	    <div slot="footer" >
	          <el-button @click="changeTableVisible=false">取 消</el-button>
	          <el-button type="primary" @click="changForm">提交</el-button>
	     </div>
	  </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'ststem-defectpriority',
  data() {
  		return {
  			datas:[],
  			keyword:null,
  			dialogTableVisible:false,
			changeTableVisible:false,	
  			addpriorityParam:{
				priorityDesc:null,
				createBy:null,
				createTime:null,
				priorityName:null
			},
			changePriority:{
				priorityCode:null,
				priorityDesc:null,
				moduleState:null,
				createBy:null,
				createTime:null,
				modifyBy:null,
				modifyTime:null,
				priorityName:null
			}
  			
  		}
  	},
  methods:{
	  openchange(row){
		  this.changeTableVisible=true;
		this.changePriority.priorityCode=row.priorityCode,
		this.changePriority.priorityDesc=row.priorityDesc,
		this.changePriority.moduleState=row.moduleState,
		this.changePriority.createBy=row.createBy,
		this.changePriority.createTime=row.createTime,
		this.changePriority.modifyBy=row.modifyBy,
		this.changePriority.modifyTime=row.modifyTime,
		this.changePriority.priorityName=row.priorityName 
		 
	  },
	  changForm(){
		  this.$http.post("/priority/save",this.changePriority).then(resp =>{
			  if(resp.data.flag==true){
				  this.changeTableVisible=false;
				  this.changePriority={};
			  }
		  })
	  },
	  open(){
		this.dialogTableVisible=true;  
	  },
	  state(row, column, cell){
	  		 if(cell==0){
	  		 	return "不可用";
	  		 }else if(cell==1){
	  		 	return "可用";
	  		 }
	  },
	  load(){
		  const param= "?keyword="+this.keyword;
		  this.$http.get("/priority/query"+param).then(resp =>{
				  console.log("vvvvvvvvvvv"+this.keyword)
				  if(resp.data.flag=true){
					  console.log(resp.data.data)
					  this.datas= resp.data.data;
				  }
		  })
	  },
	  /* 添加优先级的方法*/
		  
	  addPriority(){
		  this.dialogTableVisible=true;
		  this.$http.post("/priority/add",this.addpriorityParam).this(resp =>{
			  if(resp.data.flag == true){
				  this.$message({
				    message: '添加成功',
				    type: 'success'
				  });
			  }else{
				   this.$message.error(resp.data.message);
			  }
			  
		  })
		  this.dialogTableVisible=false;
			  this.addpriorityParam={};
	  },
	 
  },
  created() {
  	this.load();
  }
  
}
</script>
<style>
	
</style>

